import customerService from '../../services/customer'
import * as types from '../mutation-types'
// initial state
const state = {
  provinceAndCity: []

}

// getters
const getters = {
}

// actions
const actions = {
  loadProvinceAndCity({commit}) {
    return new Promise((resolve,reject) =>{
      customerService.loadCitySelectServer(function(data){
        commit(types.LOAD_PROVINCE_AND_CITY,data);
        resolve(data);
      });
    })
  }
}

// mutations
const mutations = {
  [types.LOAD_PROVINCE_AND_CITY] (state, data) {
    state.provinceAndCity = [{id:'',name:'全部'}];
    for(let i=0;i<data.data.length;i++) {
      state.provinceAndCity.push(data.data[i]);
    }
    // state.provinceAndCity = data.data;
  }
}

export default {
  state,
  getters,
  actions,
  mutations
}
